package tests;



import java.io.IOException;

import model.TransitionRestrictionHashTable;
import model.VariableHashTable;
import net.sourceforge.jeval.EvaluationException;
import exception.ExtraCharactersException;
import exception.IllegalCharacterSequenceException;
import exception.LessCharactersExeption;
import exception.NoRuleException;
import exception.UninitializedVariableException;
import guard_grammar.Evaluation;


/** Class for testing of the guard grammar
 * @author DarkoLaptop2
 *
 */
public class GuardGrammarTester 
{
	public static VariableHashTable variableSymbolTable = new VariableHashTable(); 
	public static TransitionRestrictionHashTable trasitionSymbolTable = new TransitionRestrictionHashTable();
	
	/** Main method
	 * @param args
	 * @throws IOException
	 * @throws EvaluationException
	 * @throws UninitializedVariableException
	 * @throws IllegalCharacterSequenceException
	 * @throws LessCharactersExeption
	 * @throws ExtraCharactersException
	 * @throws NoRuleException
	 */
	public static void main(String[] args) throws IOException, EvaluationException, UninitializedVariableException, IllegalCharacterSequenceException, LessCharactersExeption, ExtraCharactersException, NoRuleException
	{
			
		
		//***************** evaluacija na izraz ****************
		/*Evaluator e = new Evaluator();
		int xyz=3;
		String b = e.evaluate("((2>"+xyz+") || ("+xyz+">=2+"+xyz+")) && ((1==123) || (1!=1))");
		if(b.equals("1.0"))
		{
			System.out.println("true");
		}
		else
		{
			System.out.println("false");
		}*/
		
		
		//************** testing the update evaluation **************
		
		String[] s1 = {"x=0;x=x+1;"};		
		
		Evaluation e1 = new Evaluation();
		
		for(int i=0;i<s1.length;i++)
		{
			System.out.println("***************** EVALUATION"+ i+"****************");
			e1.evaluateUpdate(s1[i],variableSymbolTable);
			
		}
		System.out.println("Symbol table:");
		System.out.println(variableSymbolTable.toString());
		
		
		
		//************** testing the guard evaluation **************
		
		/*String[] s = {"(x<3)","(y>2|2>=1+1+1)|x<3","(y>xyz+2|xyz+2+3<=b1)&(x12<3+8)"};

		Evaluation e2 = new Evaluation();
		
		for(int i=0;i<s.length;i++)
		{
			System.out.println("***************** EVALUATION"+ i+"****************");
			System.out.println(e2.evaluateGuard(s[i]));
		}*/
		
		
		//************** testing the restriction evaluation **************
		
//		RestrictionEvaluation restriction = new RestrictionEvaluation("restriction.txt");
//		restriction.checkRestriction();
//		System.out.println(trasitionSymbolTable.toString());
		VariableHashTable variablesTable=new VariableHashTable();
		variablesTable.insertVariable("x",0);
		System.out.println("TUKAT");
		Evaluation.evaluateUpdate("x=x+1;", variablesTable);
//		Evaluation.evaluateGuard("x<3",variablesTable);
		System.out.println(variablesTable);
	}

}
